

clear
capture log close
set more off

*** TABLE A1

clear
use crecs_1990
append using crecs_1993,force
append using crecs_1997,force
append using crecs_2001,force
append using crecs_2005,force
append using crecs_2009,force
append using crecs_2015,force
tostring stories,replace
tab over65

tab hhfaminc_1990
replace hhfaminc_1990=moneypy if year==1990
capture drop _merge

tab typehuq
drop if missing(typehuq)
replace typehuq=2 if typehuq==3 //single family house
replace typehuq=3 if typehuq>3 //apartment

** central ac
gen centralac=(cooltype==1)
replace centralac=1 if coolmain==1 & (year==1990 | year==1993)


**children yes or no
gen age14=0

forval i=2/14 { 
replace age14=1 if agehhmemcat`i'==1| agehhmemcat`i'==2|agehhmemcat`i'==3
}

tab numfrig // no of refridge

tab coolmain
replace coolmain=0 if coolmain==9 /
*** over 65 uses hhage because no over 65 and 1993 data does not have hhage

encode stories,gen(hh_stories)

rename regionc region
tostring region,replace
encode region,gen(hh_region)

drop if kwh== 999999 

gen lnkwh=ln(kwh)
replace swimpool=(swimpool==1)
drop if bedroom==-2


tab year
rename homearea sqft


merge m:1 division year using division_price
keep if _merge==3

gen lnsqft=ln(sqft)
gen cdd=cdd65*100
gen hdd=hdd65*100

drop if division==.
drop if price==.
drop if typehuq==.

gen heatele=(fuelheat==5)
gen waterele=(fuelh2o==5)

save recs1990_2015.dta,replace

****

use recs1990_2015,clear

sum kwh year price hhfaminc_1990 own division typehuq famsize over65 male white ///
hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)


outreg2 using myreg.doc, replace ctitle(All)


**** california


gen cddcentralac=cdd*centralac
gen hddheatele=hdd*heatele

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele cddcentralac hddheatele
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(All-interaction terms)


reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele cddcentralac hddheatele ///
hhage
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(All-interaction terms, householder age(no data for 1993))

gen payhh=(elpay==1|pelheat==1|pelac==1)




****single family houses


keep if typehuq==2

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65 male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(Single family houses)

replace lrgstate=2 if reportable_domain==26
keep if lrgstate==2

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65 male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(California 1993-2009)


** all single family homes
use recs1990_2015,clear

keep if hh_type==2


reg lnkwh i.year price i.hh_income own i.division famsize over65  white ///
i.hh_yearmade   sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele
estimates store results3

esttab results3, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, replace ctitle(Single family house 1990-2015)





**** add more vars. TABLE A2


gen cddcentralac=cdd*centralac
gen hddheatele=hdd*heatele

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele cddcentralac hddheatele
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(All-interaction terms)


reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele cddcentralac hddheatele ///
hhage
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(All-interaction terms, householder age(no data for 1993))

gen payhh=(elpay==1|pelheat==1|pelac==1)

reg lnkwh i.year price ib1.hhfaminc_1990 own ib1.division ib1.typehuq famsize over65  male white ///
i.hh_yearmade sqft bedrooms swimpool hdd cdd centralac numfrig heatele waterele cddcentralac hddheatele ///
hhage payhh
estimates store results1

esttab results1, b(3) se(3) scalars(r2) star( * 0.10 ** 0.05 *** 0.01)
outreg2 using myreg.doc, append ctitle(All-interaction terms, householder age(no data for 1993),pay for electricity)


